package com.hanter.demo.taskstack;

import android.content.Intent;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;

public class BActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_b);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(this, CActivity.class);
//        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_FORWARD_RESULT);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_TASK_ON_HOME
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP
//                    | Intent.FLAG_ACTIVITY_NO_HISTORY
//                    | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT
//                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                    | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

//        intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        startActivity(intent);
    }
}
